package xyz.scootaloo.oj.leetcode

import org.junit.Test
import xyz.scootaloo.common.TestDsl
import xyz.scootaloo.oj.ds.ListNode
import xyz.scootaloo.oj.ds.helper.CollectionBuilder

/**
 * @author flutterdash@qq.com
 * @since 2021/7/10 15:21
 */
class P83 : TestDsl {

    fun deleteDuplicates(head: ListNode?): ListNode? {
        if (head == null)
            return null
        var node = head
        while (node!!.next != null) {
            if (node.next.`val` == node.`val`) {
                node.next = node.next.next
            } else {
                node = node.next
            }
        }

        return head
    }

    @Test
    fun test0() {
        val head1 = deleteDuplicates(CollectionBuilder.initNode(1, 1, 2))
        pause()
        val head2 = deleteDuplicates(CollectionBuilder.initNode(1, 1, 2, 3, 3))
        pause()
    }

}
